﻿@model IEnumerable<Db8.ViewModels.ClaimViewModel>
@{
    ViewBag.PageId = "Summary";
    Layout = "~/Views/Mobile/_Layout.cshtml";
}
<div data-role="page" id="@ViewBag.PageId" class="type-home" data-theme="a">
    <div data-role="header" data-position="fixed">
        <div data-role="navbar" role="navigation">
            <ul class="ui-grid-b">
            <li class="ui-block-a">@Html.ActionLink("SEARCH", "Index", "Mobile", new { search = Request.QueryString["search"] }, new { @class = "no-Ajax ui-btn ui-btn-up-b", rel = "external" })</li>
            <li class="ui-block-b">@Html.ActionLink("BROWSE", "Browse", "Mobile", new { search = Request.QueryString["search"] }, new { @class = "no-Ajax ui-btn ui-btn-up-b", rel = "external" })</li>
            <li class="ui-block-c">@Html.ActionLink("SUMMARY", "Summary", "Mobile", new { search = Request.QueryString["search"] }, new { @class = "no-Ajax ui-btn ui-btn-up-b ui-btn-active", rel = "external" })</li>
            </ul>
        </div>
@using (Html.BeginForm("Index", "Mobile", FormMethod.Get, new { rel = "external" }))
{
<div style="margin: 0.4em;" id="searchinput">
    <input type="search" name="search" id="search" value="@Request.QueryString["search"]" data-theme="b" />
</div>
}
        <div>
            <a href="@Url.Action("Reset")" rel="external" data-role="button" data-inline="true" >Reset Session</a>
            <a id="PrintButton" rel="external" data-role="button" data-inline="true">Print Now</a>
            <a id="SelectAllButton" rel="external" data-role="button" data-inline="true">Select All</a>
        </div>
    </div>
    <div data-role="content">
    <div id="SummaryText">
    @foreach (var item in Model) {
        <p><strong>CLAIM: @item.Claim.Statement</strong></p>
        foreach (var cc in item.CounterClaims)
        {
        <p>
        <strong>WE SAY: @cc.Claim.Statement</strong>
        </p>
        <p>
        @Html.Raw(@cc.AbstractHtml)
        </p>
        }
        <br />
    }
    </div>
    </div>
    <div data-role="footer" data-theme="a" data-position="fixed" style="text-align: center; padding:0;">
        <div style="paddding:0;margin:0;">
            <a class="no-Ajax" rel="external" href="@Url.Action("ViewMode", "Home", new { mode = "full" })">view full site</a>
        </div>
    </div>
</div>
@section scripts {
<script type="text/javascript">

    function selectElement(element) {
        var doc = document;
        //var text = doc.getElementById(element);

        if (doc.body.createTextRange) { // ms
            var range = doc.body.createTextRange();
            range.moveToElementText(element);
            range.select();
        } else if (window.getSelection) {
            var selection = window.getSelection();
            if (selection.setBaseAndExtent) { // webkit
                selection.setBaseAndExtent(element, 0, element, 1);
            } else { // moz, opera
                var range = doc.createRange();
                range.selectNodeContents(element);
                selection.removeAllRanges();
                selection.addRange(range);
            }
        }
    }

    $("#SelectAllButton").click(function (evt) {
        evt.preventDefault();
        selectElement($("#SummaryText")[0]);
    });

    $("#PrintButton").click(function (evt) {
        evt.preventDefault();
        var win = window.open("");
        win.document.writeln("<html><body>");
        win.document.writeln($("section.summary").html());
        win.document.writeln("</body></html>");
        win.document.close();
        win.print()
        win.close();

    });
</script>
}